package com.shopping.dao;

import com.shopping.pojo.Collection;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
@Mapper
public interface CollectionDao {

    String TABLE_NAME = "collection";
    String INSERT_FIELDS = "type, user_id, id";
    String SELECT_FIELDS = "type, user_id, id";

    @Insert({"insert into ", TABLE_NAME, "(", INSERT_FIELDS, ") values(#{type}, #{userId}, #{id})"})
    int insert(Collection collection);

    @Select({"select ", SELECT_FIELDS, "from", TABLE_NAME, " where user_id=#{userId} and id=#{id}"})
    Collection selectById(@Param("userId") int userId, @Param("id") int id);

}
